﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.ComponentModel;
using VIBlend.WPF.Controls;

namespace AnonsaiWPF.CSharp.NavigationPaneDemos
{
    /// <summary>
    /// Interaction logic for NavigationPanesAddRemove.xaml
    /// </summary>
    public partial class NavigationPanesAddRemove : Window, IWindow
    {
        public void SetTheme()
        {
        }
  
        public NavigationPanesAddRemove()
        {
            InitializeComponent();
            if (this.OutlookPane != null)
            {
                this.OutlookPane.SelectionChanging += new EventHandler<CancelEventArgs>(OutlookPane_SelectionChanging);
                this.OutlookPane.SelectionChanged += new EventHandler(OutlookPane_SelectionChanged);
                this.OutlookPane.ItemResizing += new EventHandler<CancelEventArgs>(OutlookPane_ItemResizing);
                this.OutlookPane.ItemResized += new EventHandler(OutlookPane_ItemResized);
            }
        }
    
        void OutlookPane_ItemResized(object sender, EventArgs e)
        {
            this.EventsLog.Items.Add("ItemResized  " + DateTime.Now.ToLongTimeString());
        }

        void OutlookPane_ItemResizing(object sender, CancelEventArgs e)
        {
            this.EventsLog.Items.Add("ItemResizing  " + DateTime.Now.ToLongTimeString());
        }

        void OutlookPane_SelectionChanged(object sender, EventArgs e)
        {
            this.EventsLog.Items.Add("ExpandedChanged  " + DateTime.Now.ToLongTimeString());
        }

        void OutlookPane_SelectionChanging(object sender, CancelEventArgs e)
        {
            this.EventsLog.Items.Clear();
            this.EventsLog.Items.Add("ExpandedChanging  " + DateTime.Now.ToLongTimeString());
        }

        private void ExpandTrue_Checked(object sender, RoutedEventArgs e)
        {
            if (this.OutlookPane == null)
                return;

            this.OutlookPane.EnableCollapseMode = true;
        }

        private void ExpandFalse_Checked(object sender, RoutedEventArgs e)
        {
            if (this.OutlookPane == null)
                return;

            this.OutlookPane.EnableCollapseMode = false;
        }

        private void ResizeTrue_Checked(object sender, RoutedEventArgs e)
        {
            if (this.OutlookPane == null)
                return;

            this.OutlookPane.EnableResize = true;

        }

        private void ResizeFalse_Checked(object sender, RoutedEventArgs e)
        {
            if (this.OutlookPane == null)
                return;

            this.OutlookPane.EnableResize = false;

        }

        public Grid Root
        {
            get
            {
                return this.RootVisual;
            }
        }

        public void DetachContent()
        {
            RemoveLogicalChild(Content);
        }

        private void AddItem_Click(object sender, RoutedEventArgs e)
        {
            if (this.OutlookPane == null)
                return;

            int maxItems = 10;

            if (this.OutlookPane.Items.Count < maxItems)
            {
                OutlookPaneItem item = new OutlookPaneItem();
                item.DefaultHeader = "New Item";
                item.DisplayHeader = "New Item";
                item.CollapsedDefaultHeader = "N";
                item.CollapsedStatusContent = "N";
                this.OutlookPane.Items.Add(item);

            }
        }

        private void RemoveItem_Click(object sender, RoutedEventArgs e)
        {
            if (this.OutlookPane == null)
                return;

            if (this.OutlookPane.SelectedItem != null)
            {
                this.OutlookPane.Items.Remove(this.OutlookPane.SelectedItem);

                if (this.OutlookPane.Items.Count > 0)
                {
                    this.OutlookPane.SelectedItem = this.OutlookPane.Items[0] as OutlookPaneItem;
                }
            }
        }

        private void DisableItem_Click(object sender, RoutedEventArgs e)
        {
            if (this.OutlookPane == null)
                return;

            if (this.OutlookPane.SelectedItem != null)
            {
                this.OutlookPane.SelectedItem.IsEnabled = false;

                if (this.OutlookPane.Items.Count > 0)
                {
                    this.OutlookPane.SelectedItem = this.OutlookPane.Items[0] as OutlookPaneItem;
                }
            }
        }

        private void IsStatusVisible_Checked(object sender, RoutedEventArgs e)
        {
            if (this.OutlookPane == null)
                return;

            this.OutlookPane.ShowStatusItem();
        }

        private void IsStatusHidden_Checked(object sender, RoutedEventArgs e)
        {
            if (this.OutlookPane == null)
                return;

            this.OutlookPane.HideStatusItem();
        }

        private void EnableItemsMenu_Checked(object sender, RoutedEventArgs e)
        {
            if (this.OutlookPane == null)
                return;

            this.OutlookPane.ShowOverflowButton();
        }

        private void DisableItemsMenu_Checked(object sender, RoutedEventArgs e)
        {
            if (this.OutlookPane == null)
                return;

            this.OutlookPane.HideOverflowButton();
        }  
    }
}
